<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>批量打币</title>

    <link href="../plugin/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.css" rel="stylesheet"/>
    <link href="../plugin/sweetalert-6.6.2/sweetalert2.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-3.3.7/plugin/file_input/fileinput.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
    <link href="../plugin/jquery-zoomify/zoomify.min.css" rel="stylesheet"/>

    <script src="../plugin/jquery-3.2.1/jquery-3.2.1.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/file_input/fileinput.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/file_input/local_zh.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="../plugin/sweetalert-6.6.2/sweetalert2.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.formautofill.min.js"></script>
    <script src="../plugin/jquery-zoomify/zoomify.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.serializejson.js"></script>
    <script src="../plugin/soul/batchs.js"></script>
    <script src='../base/base.js'></script>
</head>
<body>

<div class="modal fade" data-backdrop="static" id="wallet_modal_edit_play_moneys">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
                <h4 class="modal-title">
                    <b>上传excel</b>
                </h4>
            </div>
            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="form-group"><label class="col-sm-2 control-label">批量打币文件:</label>
                        <div class="col-sm-9">
                            <form id="inputForm" class="form" enctype="multipart/form-data">
                                <input type="file" id="file" name="file" class="form-control">
                            </form>
                            &nbsp;&nbsp;
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-primary" onclick="batch_play_coin.file()">确认</button>
                    <button class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        var resp = AjaxUtil.isLogin();
        if (!resp) return;
        var module = 'batch_play_coin';
        var query = [];
        // 工具条配置
        var toolbar = {
            default: [false, false, false, false],// back;add;edit;remove
            dialog: [50, 2, 9],//对话框参数:模态框宽度(百分比);表单标题宽度;表单输入框宽度
            extra: [{
                name: '下载excel模板',
                glyphicon: 'list',
                onclick: 'downLoadExcel',
            }, {
                name: '上传excel',
                glyphicon: 'list',
                onclick: 'upLoadExcel',
            }, {
                name: '批量打币',
                glyphicon: 'list',
                onclick: 'batchCoin',
            }]
        };
        var bootstrapTable = {
            columns: [{
                checkbox: true
            }, {
                field: 'batchPlayCoinId',
                title: '批量打币编号',
                align: 'center',
            }, {
                field: 'userEmail',
                title: '会员邮箱',
                align: 'center',
            }, {
                field: 'coinType',
                title: '币种',
                align: 'center',
            }, {
                field: 'coinSum',
                title: '打币数量',
                align: 'center',
            }, {
                field: 'operation',
                title: '操作',
                align: 'center',
            }, {
                field: 'remark',
                title: '备注',
                align: 'center',
            }, {
                field: 'coinStatus',
                title: ' 打币状态',
                align: 'center',
            }],
        };
        var formElement = [];
        batch_play_coin = SingleTablePageCreateUtil.createInstance(module, query, toolbar, formElement, bootstrapTable);

        batch_play_coin.downLoadExcel = function () {
            location.href = "memberCoin.xlsx";
        }

        batch_play_coin.upLoadExcel = function () {
            $('#wallet_modal_edit_play_moneys').modal('show');
        }

        batch_play_coin.file = function () {
            var formData = new FormData($("#inputForm")[0]);
            $.ajax({
                url: '/admin/batch_play_coin/file?token=' + BaseConfig.token,
                type: 'POST',
                data: formData,
                async: true,
                cache: false,
                contentType: false,
                processData: false,
                success: function (res) {
                    if (res.code == 412) {
                        SwalUtil.error(res.msg);
                    }
                    if (res.code == 200) {
                        $('#wallet_modal_edit_play_moneys').modal('hide');
                        SwalUtil.success(res.msg);
                        $('#batch_play_coin_table').bootstrapTable('refresh');
                    }
                },
            });
        }

        batch_play_coin.batchCoin = function () {
            var ids = '';
            var rows = $("#batch_play_coin_table").bootstrapTable('getSelections');
            if (rows.length == 0) {
                SwalUtil.error("您没有选中任何记录");
                return false;
            }
            for(var i=0; i<rows.length; i++){
                ids += rows[i].batchPlayCoinId;
                if(i != rows.length-1){
                    ids += ","
                }
            }
            var resp = AjaxUtil.postJson('batch_play_coin/batch', {
                ids:ids
            });
            if (resp) {
                SwalUtil.success(resp.msg);
                $('#batch_play_coin_table').bootstrapTable('refresh');
            }
        }

    });
</script>
</body>

</html>